package cn.fz.eventdemo01.controller;

import cn.fz.eventdemo01.publisher.LoginEventPublisher;
import cn.fz.eventdemo01.utils.XxResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "事件驱动管理",description = "事件驱动管理")
@RestController
@RequestMapping("/home")
@RequiredArgsConstructor
public class HomeController {
    private final LoginEventPublisher loginEventPublisher;
    @Operation(summary = "展示登录事件")
    @GetMapping("showLoginEvent")
    public XxResult showLoginEvent(@RequestParam(value = "username",defaultValue = "fz",required = false) String username){
        loginEventPublisher.publishLoginEvent(username);
        return XxResult.ok();
    }
}
